import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_public/flutter_public.dart';

/// FileName status_bar
///
/// @Author lax
/// @Date 2023/7/14
///
/// @Description

class StatusBar extends StatelessWidget {
  /// 仅web平台设置 APP会自动获取
  static double? defaultHeight;

  static Color? defaultColor;

  late final Color? color;

  StatusBar({
    super.key,
    Color? color,
  }) {
    this.color = color ?? defaultColor;
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: color,
      height: height(context),
    );
  }

  static double height([BuildContext? context]) {
    if (kIsWeb) {
      return defaultHeight ?? 0;
    }
    context ??= FlutterPublic.navigatorKey?.currentContext;
    if (context == null) {
      return defaultHeight ?? 0;
    }
    return MediaQuery.of(context).padding.top;
  }
}
